﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TSqlServer;

/// <summary>
/// TWeekPlan 的摘要说明
/// </summary>
public class TWeekPlan : TData
{
    //常量
    const string CTableName = "t_plan";
    const string CKeyName = "uid";
    //与数据表字段对应的变量
    private string FUID;
    private DateTime FPlandate;
    private string FPlantime;
    private int FPlantimeNum;
    private string FPlanContent;
    private string FPlanMans;
    private int FStatus;
    private string FInMan;
    private DateTime FInTime;
    private int FIId;
    
    public TWeekPlan()
	{
        FTableName = CTableName;
        FKeyName = CKeyName;
    }

    public TWeekPlan(string sid)
    {
        FTableName = CTableName;
        FKeyName = CKeyName;
        FKeyValue = sid;
    }

    //根据uid获得记录值
    public override void Select()
    {
        string strSql = GetSelectString();
        TSqlDB oDB = new TSqlDB(strSql);
        if (!oDB.EOF)
        {
            FUID = oDB["uid"].ToString();
            FPlandate = oDB["plandate"].ToDateTime();
            FPlantime = oDB["plantime"].ToString();
            FPlantimeNum = oDB["plantimenum"].ToInt();
            FPlanContent = oDB["plancontent"].ToString();
            FPlanMans = oDB["planmans"].ToString();
            FStatus = oDB["status"].ToInt();
            FInMan = oDB["inman"].ToString();
            FInTime = oDB["intime"].ToDateTime();
            FIId = oDB["iid"].ToInt();
        }
        oDB.Free();
    }

    //插入新记录。
    public void Insert()
    {
        //FPlanContent = FPlanContent.Substring(0, 50);
        //FPlanMans = FPlanMans.Substring(0, 50);

        string ExSql = "newid(),'" + FPlandate.ToString("yyyy-MM-dd") + "','" + FPlantime + "'," + FPlantimeNum.ToString() + ",'" + FPlanContent + "','" + FPlanMans + "',";
        ExSql += FStatus.ToString() + ",'" + FInMan + "',getdate()";
        base.Insert(ExSql);
    }

    //改变状态
    public void Update_status()
    {
        string ExSql = "status=" + FStatus.ToString(); ;
        base.Update(ExSql);
    }

    //静态，可以不用创建对象即可调用。
    public static void DeleteByID(string sID)
    {
        TData.DeleteByID(sID, CTableName, CKeyName);
    }

    public string UID
    {
        get
        {
            return FUID;
        }
        set
        {
            FUID = value;
        }
    }

    public DateTime Plandate
    {
        get
        {
            return FPlandate;
        }
        set
        {
            FPlandate = value;
        }
    }

    public string Plantime
    {
        get
        {
            return FPlantime;
        }
        set
        {
            FPlantime = value;
        }
    }

    public int PlantimeNum
    {
        get
        {
            return FPlantimeNum;
        }
        set
        {
            FPlantimeNum = value;
        }
    }

    public string PlanContent
    {
        get
        {
            return FPlanContent;
        }
        set
        {
            FPlanContent = value;
        }
    }

    public string PlanMans
    {
        get
        {
            return FPlanMans;
        }
        set
        {
            FPlanMans = value;
        }
    }

    public int Status
    {
        get
        {
            return FStatus;
        }
        set
        {
            FStatus = value;
        }
    }

    public string InMan
    {
        get
        {
            return FInMan;
        }
        set
        {
            FInMan = value;
        }
    }

    public DateTime InTime
    {
        get
        {
            return FInTime;
        }
        set
        {
            FInTime = value;
        }
    }

    public int IId
    {
        get
        {
            return FIId;
        }
        set
        {
            FIId = value;
        }
    }
}
